
def sum2(nums, target):
    temp = []
    result = []
    for value in nums:
        dec  = target - value
        if dec in temp:
            result.append([value, dec])
        else:
            temp.append(value)
    return result 
        
def sum3(nums):
    tuples = []
    tuple_values = []
    for index, value in enumerate(nums):
        obj = 0 - value
        obj_list = nums[0:index] + nums[index+1:len(nums)]
        sum2value_list = sum2(obj_list, obj)
        if sum2value_list:
            for sum2value in sum2value_list:
                sum2value.append(value)
                if set(sum2value) not in tuples:
                    tuples.append(set(sum2value))
                    tuple_values.append(sum2value)

    return tuple_values


if __name__ == '__main__':
    #nums = [-1, 0, 1, 2, -1, -4]
    #nums = [-4,-2,-2,-2,0,1,2,2,2,3,3,4,4,6,6]
    nums = [-12,4,12,-4,3,2,-3,14,-14,3,-12,-7,2,14,-11,3,-6,6,4,-2,-7,8,8,10,1,3,10,-9,8,5,11,3,-6,0,6,12,-13,-11,12,10,-1,-15,-12,-14,6,-15,-3,-14,6,8,-9,6,1,7,1,10,-5,-4,-14,-12,-14,4,-2,-5,-11,-10,-7,14,-6,12,1,8,4,5,1,-13,-3,5,10,10,-1,-13,1,-15,9,-13,2,11,-2,3,6,-9,14,-11,1,11,-6,1,10,3,-10,-4,-12,9,8,-3,12,12,-13,7,7,1,1,-7,-6,-13,-13,11,13,-8]
    print sum3(nums)

        
